package com.yuexunit.operationman.nbsy.module.OperationInventory.ui;

import android.view.View;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.base.BaseKJActivity;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.OperationInventory.adapter.PreviewInventoryAdapter;
import com.yuexunit.operationman.nbsy.widget.FixedSwipeListView;

import org.kymjs.kjframe.utils.PreferenceHelper;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2017/8/14 0014.
 */

public class Act_OperationInventory_Preview extends BaseKJActivity {

    @Bind(R.id.tv_patient_name)
    TextView tvPatientName;
    @Bind(R.id.tv_patient_sex)
    TextView tvPatientSex;
    @Bind(R.id.tv_patient_visitno)
    TextView tvPatientVisitno;
    @Bind(R.id.tv_patient_disease)
    TextView tvPatientDisease;
    @Bind(R.id.listview)
    FixedSwipeListView listview;
    @Bind(R.id.preview_02)
    TextView preview02;
    @Bind(R.id.preview_03)
    TextView preview03;
    @Bind(R.id.preview_05)
    TextView preview05;
    @Bind(R.id.preview_06)
    TextView preview06;
    @Bind(R.id.preview_08)
    TextView preview08;
    @Bind(R.id.preview_09)
    TextView preview09;
    @Bind(R.id.preview_11)
    TextView preview11;
    @Bind(R.id.preview_12)
    TextView preview12;

    PreviewInventoryAdapter adapter;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_operationinventory_preview);
        ButterKnife.bind(this);
    }


    @Override
    public void initData() {
        setTitle();
        adapter = new PreviewInventoryAdapter(listview, AppConfig.INVENTORYBEAN.getObject().getCheckItemList(), R.layout.item_operationinventory_preview);
        listview.setAdapter(adapter);
        setContent();
    }

    private void setTitle() {
        tvPatientName.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getPatientName());
        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getPatientSex().equals("1")) {
            tvPatientSex.setText("男");
        } else if (AppConfig.INVENTORYBEAN.getObject().getCheck().getPatientSex().equals("2")) {
            tvPatientSex.setText("女");
        } else {
            tvPatientSex.setText("不详");
        }
        tvPatientVisitno.setText("住院号" + AppConfig.INVENTORYBEAN.getObject().getCheck().getInHospitalNo());
        tvPatientDisease.setText(PreferenceHelper.readString(aty, AppConfig.PATIENT_INFO, AppConfig.PATIENT_DISEASE));
    }

    private void setContent() {
        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getSignInstrumentBefore() != null) {
            preview02.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getSignInstrumentBefore());
        }
        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getSignCircurtBefore() != null) {
            preview03.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getSignCircurtBefore());
        }

        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseBefore() != null) {
            preview05.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseBefore());
        }
        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseBefore2() != null) {
            preview06.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseBefore2());
        }

        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseAfter() != null) {
            preview08.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseAfter());
        }
        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseAfter2() != null) {
            preview09.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getBodyCloseAfter2());
        }

        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getSkinCloseAfter() != null) {
            preview11.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getSkinCloseAfter());
        }
        if (AppConfig.INVENTORYBEAN.getObject().getCheck().getSkinCloseAfter2() != null) {
            preview12.setText(AppConfig.INVENTORYBEAN.getObject().getCheck().getSkinCloseAfter2());
        }
    }

    @OnClick({R.id.titlebar_docadvice_img_back, R.id.tv_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.titlebar_docadvice_img_back:
                finish();
                break;
            case R.id.tv_submit:
                break;
        }
    }
}
